<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@include file="/WEB-INF/common/common.jsp" %>
<%@include file="/WEB-INF/common/header.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>添加资料</title>
</head>
<script>
    $(function () {
        $('#check').click(function () {
            var platform = $('#platform').val();
            var department = $('#department').val();
            var school = $('#school').val();
            var photo = $('#photo').val();
            var tap = $('#tap').val();
            var title = $('#title').val();
            var ok = true;
            if (platform == null || platform == "") {
                $('#platform1').html("请选择平台！");
                ok = false;
            } else {
                $('#platform1').html("");
            }
            if (department == null || department == "") {
                $('#department1').html("请选择方向！");
                ok = false;
            } else {
                $('#department1').html("");
            }
            if (school == null || school == "") {
                $('#school1').html("请选择院校！");
                ok = false;
            } else {
                $('#school1').html("");
            }
            if (photo == null || photo == "") {
                $('#photo1').html("请上传照片！");
                ok = false;
            } else {
                $('#photo1').html("");
            }
            if (tap == null || tap == "") {
                $('#tap1').html("请添加标签！");
                ok = false;
            } else {
                $('#tap1').html("");
            }
            if (title == null || title == "") {
                $('#title1').html("请输入文案！");
                ok = false;
            } else {
                $('#title1').html("");
            }
            if (ok) {
                $('#form').submit();
            }
        });
    });

</script>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4">
            <form id="form" class="form-group" method="post" action="${ctx}/addData" enctype="multipart/form-data">
                <br><br>
                <input type="hidden" value="${requestScope.token}" name="token">
                <p class="h3 text-center">上传资料</p>
                <div style="color: red;font-weight:bold;font-size: 16px;float: right">${param.msg}</div>
                <label>选择方向：</label>
                <select class="form-control" name="department" id="department">
                    <option></option>
                    <c:forEach items="${requestScope.departments}" var="department">
                        <option value="${department.name}">${department.name}</option>
                    </c:forEach>
                </select>
                <div id="department1" class="text-center" style="color: red;font-weight: bold;font-size: 14px"></div>
                <label>选择院校：</label>
                <select class="form-control" name="school" id="school">
                    <option></option>
                    <c:forEach items="${requestScope.schools}" var="school">
                        <option value="${school.name}">${school.name}</option>
                    </c:forEach>
                </select>
                <div id="school1" class="text-center" style="color: red;font-weight: bold;font-size: 14px"></div>
                <label>上传图片：</label>
                <input type="file" multiple class="form-control" name="file" id="photo">
                <div id="photo1" class="text-center" style="color: red;font-weight: bold;font-size: 14px"></div>
                <div style="color: red;font-size: 16px;float: right">限制上传图片三张</div>
                <label>填写文案：</label>
                <input type="text" class="form-control" value="${requestScope.data.title}" name="title" id="title"
                       placeholder="请输入文案。" maxlength="35">
                <div id="title1" class="text-center" style="color: red;font-weight: bold;font-size: 14px"></div>
                <label>添加标签：</label>
                <select class="form-control" name="tap" id="tap">
                    <option></option>
                    <c:forEach items="${requestScope.taps}" var="tap">
                        <option value="${tap.name}">${tap.name}</option>
                    </c:forEach>
                </select>
                <div id="tap1" class="text-center" style="color: red;font-weight: bold;font-size: 14px"></div>
                <label>选择平台：</label>
                <select class="form-control" name="platform" id="platform">
                    <option></option>
                    <c:forEach items="${requestScope.platforms}" var="platform">
                        <option value="${platform.name}">${platform.name}</option>
                    </c:forEach>
                </select>
                <div id="platform1" class="text-center" style="color: red;font-weight: bold;font-size: 14px"></div>
                <br> <br>
                <input type="button" id="check" class="btn btn-success form-control" value="立即上传">
            </form>
        </div>
        <div class="col-md-4">
            <div style="height: 100px"></div>

        </div>
    </div>
</div>


</body>
</html>
<%@include file="/WEB-INF/common/bottom.jsp" %>
